home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / nihcl-30.lha / nihcl-3.0 / lib / ArrayOb.h < prev    next >
C/C++ Source or Header  |  1990-05-19  |  2KB  |  76 lines

  1. #ifndef    ARRAYOB_H
  2. #define    ARRAYOB_H
  3.  
  4. /*$Header: /afs/alw.nih.gov/unix/sun4_40c/usr/local/src/nihcl-3.0/share/lib/RCS/ArrayOb.h,v 3.0 90/05/20 00:18:56 kgorlen Rel $*/
  5.  
  6. /* ArrayOb.h -- declarations for array of object pointers
  7.  
  8.     THIS SOFTWARE FITS THE DESCRIPTION IN THE U.S. COPYRIGHT ACT OF A
  9.     "UNITED STATES GOVERNMENT WORK".  IT WAS WRITTEN AS A PART OF THE
  10.     AUTHOR'S OFFICIAL DUTIES AS A GOVERNMENT EMPLOYEE.  THIS MEANS IT
  11.     CANNOT BE COPYRIGHTED.  THIS SOFTWARE IS FREELY AVAILABLE TO THE
  12.     PUBLIC FOR USE WITHOUT A COPYRIGHT NOTICE, AND THERE ARE NO
  13.     RESTRICTIONS ON ITS USE, NOW OR SUBSEQUENTLY.
  14.  
  15. Author:
  16.     K. E. Gorlen
  17.     Computer Systems Laboratory, DCRT
  18.     National Institutes of Health
  19.     Bethesda, MD 20892
  20.  
  21. $Log:    ArrayOb.h,v $
  22.  * Revision 3.0  90/05/20  00:18:56  kgorlen
  23.  * Release for 1st edition.
  24.  * 
  25. */
  26.  
  27. #include "Collection.h"
  28.  
  29. class ArrayOb: public Collection {
  30.     DECLARE_MEMBERS(ArrayOb);
  31.     Object** v;
  32.     unsigned sz;
  33.     void allocSizeErr() const;
  34.     void indexRangeErr() const;
  35. protected:        // storer() functions for object I/O
  36.     virtual void storer(OIOofd&) const;
  37.     virtual void storer(OIOout&) const;
  38. public:
  39.     ArrayOb(unsigned size =DEFAULT_CAPACITY);
  40.     ArrayOb(const ArrayOb&);
  41.     ~ArrayOb();
  42.     Object*& elem(int i)            { return v[i]; }
  43.     const Object *const& elem(int i) const    { return v[i]; }
  44.     bool operator!=(const ArrayOb& a) const    { return !(*this==a); }
  45.     void operator=(const ArrayOb&);
  46.     bool operator==(const ArrayOb&) const;
  47.     Object*& operator[](int    i)    {
  48.         if ((unsigned)i >= sz) indexRangeErr();
  49.         return v[i];
  50.     }
  51.     const Object *const& operator[](int i) const    {
  52.         if ((unsigned)i >= sz) indexRangeErr();
  53.         return v[i];
  54.     }
  55.     virtual Collection& addContentsTo(Collection&) const;
  56.     virtual Object*& at(int i);
  57.     virtual const Object *const& at(int i) const;
  58.     virtual unsigned capacity() const;
  59.     virtual int compare(const Object&) const;
  60.     virtual void deepenShallowCopy();
  61.     virtual Object* doNext(Iterator&) const;
  62.     virtual unsigned hash() const;
  63.     virtual bool isEqual(const Object&) const;
  64.     virtual void reSize(unsigned);
  65.     virtual void removeAll();
  66.     virtual unsigned size() const;
  67.     virtual void sort();
  68.     virtual const Class* species() const;
  69. private:                // shouldNotImplement();
  70.     virtual    Object* add(Object&);
  71.     virtual unsigned occurrencesOf(const Object&) const;
  72.     virtual Object* remove(const Object&);
  73. };
  74.  
  75. #endif
  76.